package com.ruanyun.modular.admin.controller;

import com.ruanyun.base.pojo.page.LayuiPageInfo;
import com.ruanyun.modular.admin.entity.TProductionProcess;
import com.ruanyun.modular.admin.model.params.TProductionProcessParam;
import com.ruanyun.modular.admin.service.TProductionProcessService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 生产工艺控制器
 *
 * @author zs
 * @Date 2021-04-17 09:05:34
 */
@Controller
@RequestMapping("/tProductionProcess")
public class TProductionProcessController extends BaseController {

    private String PREFIX = "/tProductionProcess";

    @Autowired
    private TProductionProcessService tProductionProcessService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/tProductionProcess.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/tProductionProcess_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/tProductionProcess_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(TProductionProcessParam tProductionProcessParam) {
        return this.tProductionProcessService.add(tProductionProcessParam);
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(TProductionProcessParam tProductionProcessParam) {
        return this.tProductionProcessService.update(tProductionProcessParam);
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(TProductionProcessParam tProductionProcessParam) {
        return this.tProductionProcessService.updateDelFlagById((long)tProductionProcessParam.getId());
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(TProductionProcessParam tProductionProcessParam) {
        TProductionProcess detail = this.tProductionProcessService.getById(tProductionProcessParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(TProductionProcessParam tProductionProcessParam) {
        return this.tProductionProcessService.findPageBySpec(tProductionProcessParam);
    }

    /**
     * 启用
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/enable")
    public ResponseData enable(@RequestParam Long id) {
        return this.tProductionProcessService.enableById(id);
    }

    /**
     * 禁用
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/disable")
    public ResponseData disable(@RequestParam Long id) {
        return this.tProductionProcessService.disableById(id);
    }

}


